//@import "bootstrap/bootstrap.less";
@import "bootstrap/buttons.less";
@import "bootstrap/variables.less";
@import "bootstrap/mixins.less";
@import "variables.less";
@import "mixins.less";

// Body
body {
  //padding-top: 60px;
}

// Navigation bar
.navbar-inner-text (@base, @text-color) {
  text-shadow: 0 1px 0 contrast(@base, lighten(@base, 15%), darken(@base, 15%));
  color: @text-color;
  @caret-color: average(@base, @text-color);
  @caret-hover-color: average(@caret-color, @text-color);

  .caret {
    border-bottom-color: @caret-color;
    border-top-color: @caret-color;
  }

  &:hover .caret, &:focus .caret {
    border-bottom-color: @caret-hover-color;
    border-top-color: @caret-hover-color;
  }
}

.brand (@color, @dark, @light) when (@color = @dark) {
  span {
    background-image: url(../img/tentacle-20x20.png);

    @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
      background-image: url(../img/tentacle-20x20@2x.png);
    }
  }
}
.brand (@color, @dark, @light) when (@color = @light) {
  span {
    background-image: url(../img/tentacle-20x20-light.png);

    @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
      background-image: url(../img/tentacle-20x20-light@2x.png);
    }
  }
}

.nowrap {
  white-space: nowrap;
}

.actioncol {
  text-align: center;
  .nowrap;

  a {
    text-decoration: none;
    color: #000;

    &.disabled {
      color: #ccc;
      cursor: default;
    }
  }
}

.navbar-background-color (@top, @bottom, @image) when (isstring(@image)) {
  #imggradient > .vertical(@top, @bottom, @image);
}

.navbar-background-color(@top, @bottom, @image) when not (isstring(@image)) {
  #gradient > .vertical(@top, @bottom);
}


.navbar-inner-color (@base, @gradientalpha: 100%, @image: false) {
  @top: lighten(@base, 25%);
  @bottom: darken(@base, 15%);

  @text-color-light: #f2f2f2;
  @text-color-dark: #333333;
  @text-color: contrast(@bottom, @text-color-dark, @text-color-light);

  .navbar-background-color(fade(@top, @gradientalpha), fade(@bottom, @gradientalpha), @image);

  .brand, .nav>li>a {
    .navbar-inner-text(@base, @text-color);
  }

  .brand {
    .brand(@text-color, @text-color-dark, @text-color-light);
  }

  .nav {
    li.dropdown.open>.dropdown-toggle, li.dropdown.active>.dropdown-toggle, li.dropdown.open.active>.dropdown-toggle {
      // invert for dropdown
      .navbar-background-color(fade(@bottom, @gradientalpha), fade(@top, @gradientalpha), @image);
    }
  }
}

#navbar .navbar-inner {
  @base: #F2F2F2;
  .navbar-inner-color(@base);

  &.transparent {
    .navbar-inner-color(@base, 60%, "../img/trans-background.png");
  }

  &.red {
    @base: #bd362f;
    .navbar-inner-color(@base);

    &.transparent {
      .navbar-inner-color(@base, 60%, "../img/trans-background.png");
    }
  }
  &.orange {
    @base: #F27728;
    .navbar-inner-color(@base);

    &.transparent {
      .navbar-inner-color(@base, 60%, "../img/trans-background.png");
    }
  }
  &.yellow {
    @base: #F2DE28;
    .navbar-inner-color(@base);

    &.transparent {
      .navbar-inner-color(@base, 60%, "../img/trans-background.png");
    }
  }
  &.green {
    @base: #77FF28;
    .navbar-inner-color(@base);

    &.transparent {
      .navbar-inner-color(@base, 60%, "../img/trans-background.png");
    }
  }
  &.blue {
    @base: #04c;
    .navbar-inner-color(@base);

    &.transparent {
      .navbar-inner-color(@base, 60%, "../img/trans-background.png");
    }
  }
  &.violet {
    @base: #7728FF;
    .navbar-inner-color(@base);

    &.transparent {
      .navbar-inner-color(@base, 60%, "../img/trans-background.png");
    }
  }
  &.black {
    @base: #383838;
    .navbar-inner-color(@base);

    &.transparent {
      .navbar-inner-color(@base, 60%, "../img/trans-background.png");
    }
  }
  &.white {
    @base: #eeeeee;
    .navbar-inner-color(@base);

    &.transparent {
      .navbar-inner-color(@base, 60%, "../img/trans-background.png");
    }
  }

  .brand span {
    background-size: 20px 20px;
    background-position: left center;
    padding-left: 24px;
    background-repeat: no-repeat;
  }
}

.octoprint-container {
  margin-top: 20px;

  /** OctoPrint application tabs */

  .tab-content {
    padding: 9px 15px;
    border-left: 1px solid #DDD;
    border-right: 1px solid #DDD;
    border-bottom: 1px solid #DDD;

    @radius: 4px;
    .border-bottom-right-radius(@radius);
    .border-bottom-left-radius(@radius);
  }

  .nav {
    margin-bottom: 0px;
  }

  .tab-content h1 {
    display: block;
    width: 100%;
    padding: 0;
    margin-bottom: 20px;
    font-size: 21px;
    line-height: 40px;
    color: #333;
    border: 0;
    border-bottom: 1px solid #E5E5E5;
    font-weight: normal;
  }

  /** Accordions */

  .accordion-heading {
    .accordion-heading-button {
      float: right;

      a {
        display: inline-block;
        padding: 8px 15px;
        font-size: 14px;
        line-height: 20px;
        color: #000;
        text-decoration: none;
        background: none;

        -webkit-box-shadow: none;
        -moz-box-shadow: none;
        box-shadow: none;
      }
    }

    a.accordion-toggle {
      display: inline-block;
    }

    [class^="icon-"],
    [class*=" icon-"] {
      color: #000;
    }
  }
}

.print-control .btn {
  padding-left: 4px;
  padding-right: 4px;
}

.upload-buttons .btn {
  margin-right: 0;
}

/** Tables */

table {
  table-layout: fixed;

  .popover-title {
    text-overflow: ellipsis;
    word-break: break-all;
  }

  th, td {
    overflow: hidden;

    // gcode files
    &.gcode_files_name {
      text-overflow: ellipsis;
      text-align: left;
      .nowrap;
    }

    &.gcode_files_action {
      width: 90px;
      .actioncol;
    }

    // timelapse files
    &.timelapse_files_name,
    &.timelapse_unrendered_name {
      text-overflow: ellipsis;
      text-align: left;
    }

    &.timelapse_files_size {
      text-align: right;
      width: 55px;
    }

    &.timelapse_unrendered_size {
      text-align: right;
      width: 55px;
    }

    &.timelapse_unrendered_count {
      text-align: right;
      width: 45px;
    }

    &.timelapse_files_action,
    &.timelapse_unrendered_action {
      width: 45px;
      .actioncol;
    }

    // user settings
    &.settings_users_name {
      text-overflow: ellipsis;
      text-align: left;
    }

    &.settings_users_active, &.settings_users_admin {
      text-align: center;
      width: 55px;
    }

    &.settings_users_actions {
      width: 60px;
      .actioncol;
    }

    // log files
    &.settings_logs_name {
      text-overflow: ellipsis;
      text-align: left;
    }

    &.settings_logs_size {
      text-align: right;
      width: 70px;
    }

    &.settings_logs_date {
      text-align: left;
      width: 130px;
    }

    &.settings_logs_action {
      width: 70px;
      .actioncol;
    }

    // Printer profiles
    &.settings_printerProfiles_profiles_name {
      text-overflow: ellipsis;
      text-align: left;
    }

    &.settings_printerProfiles_profiles_model {
      text-align: left;
      width: 250px;
    }

    &.settings_printerProfiles_profiles_action {
      width: 80px;
      .actioncol;
    }

  }
}


/** Temperature tab */

#temperature-graph {
  height: 350px;
  width: 100%;
  background-image: url("../img/graph-background.png");
  background-position: center;
  background-repeat: no-repeat;
}

.tab-content, .tab-pane {
  overflow: visible;
}

.tempInput {
  width: 50px;
}

#temp_newTemp, #temp_newBedTemp, #speed_innerWall, #speed_outerWall, #speed_fill, #speed_support,
#webcam_timelapse_interval, #webcam_timelapse_postRoll, #webcam_timelapse_fps {
  text-align: right;
}

ul.dropdown-menu li a {
  cursor: pointer;
}

/** Connection settings */

#connection_ports, #connection_baudrates, #connection_printers {
  width: 100%;
}

/** Offline & Reload overlay */

#offline_overlay,
#reloadui_overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
}

#offline_overlay {
  z-index: 10002;
}

#reloadui_overlay {
  z-index: 10001;
}

#offline_overlay_background,
#reloadui_overlay_background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #000000;
  filter:alpha(opacity=50);
  -moz-opacity:0.5;
  -khtml-opacity: 0.5;
  opacity: 0.5;
}

#offline_overlay_wrapper,
#reloadui_overlay_wrapper {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  padding-top: 60px;

  .container {
    margin: auto;
  }
}

/** Webcam */

#webcam_container {
  width: 100%;
  position: relative;
  outline: none;

  //min-height: 440px;

  .flipH {
    -webkit-transform: scaleX(-1);
    -moz-transform: scaleX(-1);
    -ms-transform: scaleX(-1);
  }

  .flipV {
    -webkit-transform: scaleY(-1);
    -moz-transform: scaleY(-1);
    -ms-transform: scaleY(-1);
  }

  .flipH.flipV {
    -webkit-transform: scaleX(-1) scaleY(-1);
    -moz-transform: scaleX(-1) scaleY(-1);
    -ms-transform: scaleX(-1) scaleY(-1);
  }

  .rotate90 {
    transform: rotate(-90deg);
  }

  .keycontrol_overlay {
    position: absolute;
    left: 10px;
    right: 10px;
    bottom: 10px;
    background: rgba(0, 0, 0, 0.5);
    font-size: 85%;
    color: white;
    padding: 0;

    kbd {
      border: 1px solid #eeeeee;
      border-radius: 3px;
      margin-left: 2px;
      margin-right: 2px;
      font-size: 90%;
      padding: 2px;
      min-width: 1em;
    }

    .keycontrol_overlay_heading {
      position: relative;
      padding: 10px;
      font-weight: bold;
    }

    .keycontrol_overlay_column {
      position: relative;
      width: 45%;
      padding: 10px;
      float: left;
    }
  }
}

/** GCODE file manager */

#files {
  .gcode_files {
    @padding: 5px;
    @scrollBar: 5px;
    @line-height: 20px;

    padding-right: @scrollBar + 2px;

    .entry {
      padding: @padding;
      line-height: @line-height;
      border-bottom: 1px solid #ddd;
      position: relative;

      &:hover {
        background-color: #f5f5f5;
      }

      .title {
        text-overflow: ellipsis;
        word-break: break-all;
      }

      .uploaded, .size, .additionalInfo {
        font-size: 85%;
        color: #999;
      }

      .action-buttons {
        position: absolute;
        bottom: @padding;
        right: @padding;
      }

      .additionalInfo {
        padding-bottom: @line-height + 2px;
      }
    }
  }

  .upload-buttons {
    margin-top: 10px;
  }

  .form-search {
    text-align: center;
    margin-bottom: 5px !important;
  }
}

/** Control tab */

#control {
  overflow: hidden;

  .jog-panel {
    float: left;
    margin-right: 19px;
  }

  h1 {
    text-align: left;
  }

  .jog-panel {
    >div {
      text-align: center;
    }

    >div.distance {
      text-align: left;
    }

    .slider {
      margin-bottom: 10px;
    }
  }

  .box {
    width: 30px;
    height: 30px;
    margin-right: 10px;
    margin-bottom: 10px;
    padding-left: 8px;
  }

  .control-box {
    display: block;
    height: 30px;
    margin-bottom: 10px;
  }

  .btn-group {
    margin-bottom: 10px;
  }

  .btn-group.distance > .btn {
    width: 43px;
    padding: 3px 0;
    height: 30px;
  }

  .slider-handle {
    width: 14px;
    height: 14px;
    margin-left: -7px;
    margin-top: -3px;
  }

  .custom_section {
    h1 {
      cursor: pointer;
    }
  }

  .custom_section_horizontal > .custom_control {
    display: inline-block;
  }

  .custom_section_vertical > .custom_control {
      display:block;
  }

  .custom_control {
    .slider {
      margin-left: 10px;
      margin-right: 10px;
      margin-bottom: 2px;
    }
  }
}

/** GCODE viewer */

#gcode {
  .progress {
    width: 582px;

    .bar {
      .transition(width 0s linear);
    }
  }

  .canvas_container {
    position: relative;
  }

  #gcode_layer_slider {
    position: absolute;
    right: 0;
    top: 0;
    height: 568px;
    float: right;

    .slider-handle {
      width: 14px;
      height: 14px;
      margin-left: -3px;
      margin-top: -7px;
    }
  }

  #gcode_command_slider {
    .slider-handle {
      width: 14px;
      height: 14px;
      margin-left: -7px;
      margin-top: -3px;
    }
  }
}

/** Terminal output */

#term {
  .terminal {
    #terminal-output, #terminal-output-lowfi {
      min-height: 340px;
      margin-bottom: 5px;
    }

    margin-bottom: 30px;
  }

  #terminal-sendpanel {
    text-align: right;
  }
}

/** Settings dialog */
#settings_dialog {
  .modal-body {
    #settings_dialog_menu {
      margin-left: 0;
    }
  }
}


#settings_appearance_managelanguagesdialog_emptylist {
  overflow: hidden;
  width: 100%;
  height: 300px;
  text-align: center;
  display: table;

  div {
    display: table-cell;
    vertical-align: middle;
  }
}

/** Footer */
.footer {
  ul {
    margin: 0;

    li {
      &:first-child {
        margin-left: 0;
      }

      display: inline;
      margin-left: 1em;
      font-size: 85%;
      a {
        color: #555;
      }
    }

  }
}

/** Notifications */

.ui-pnotify .alert a {
  color: #c09853;
}
.ui-pnotify .alert-error a,
.ui-pnotify .alert-danger a {
  color: #b94a48;
}
.ui-pnotify .alert-success a {
  color: #468847;
}
.ui-pnotify .alert-info a {
  color: #3a87ad;
}

.pnotify_additional_info {
  .pnotify_more {
    font-size: 85%;
  }
}

/** General helper classes */

.text-right {
  text-align: right;
}

.overflow_visible {
  overflow: visible !important;
}

.border_box {
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}

.hidden {
  display: none;
}

textarea.block {
  .border_box;
  width: 100%;
}

#drop_overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10000;
  display: none;

  &.in {
    display: block;
  }

  #drop_overlay_background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000000;
    filter:alpha(opacity=50);
    -moz-opacity:0.5;
    -khtml-opacity: 0.5;
    opacity: 0.5;
  }

  #drop_overlay_wrapper {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    padding-top: 60px;

    @dropzone_width: 50%;
    @dropzone_height: 100%;
    @border_color: #cccccc;

    #drop, #drop_background {
      position: absolute;
      top: 0;
      left: 0;
      margin-left: 0;
      width: 100%;
    }

    #drop_locally, #drop_locally_background {
      position: absolute;
      top: 0;
      left: 50%;
      margin-left: -50%;
      width: 50%;
      border-right: 2px dashed @border_color;
    }

    #drop_sd, #drop_sd_background {
      position: absolute;
      top: 0;
      left: 50%;
      margin-left: 0;
      width: 50%;
      border-left: 2px dashed @border_color;
    }

    .dropzone {
      height: @dropzone_height;
      z-index: 10001;

      color: #ffffff;
      font-size: 30px;

      i {
        font-size: 50px;
      }

      .text {
        display: block;
        text-align: center;
        line-height: 40px;
        position: absolute;
        width: 100%;
        bottom: 5%;

        filter:alpha(opacity=100);
        -moz-opacity:1.0;
        -khtml-opacity: 1.0;
        opacity: 1.0;
      }
    }

    .dropzone_background {
      width: @dropzone_width;
      height: @dropzone_height;

      background-color: #000000;
      filter:alpha(opacity=25);
      -moz-opacity:0.25;
      -khtml-opacity: 0.25;
      opacity: 0.25;

      &.hover {
        background-color: #000000;
        filter:alpha(opacity=50);
        -moz-opacity:0.5;
        -khtml-opacity: 0.5;
        opacity: 0.5;

      }

      &.fade {
        -webkit-transition: all 0.3s ease-out;
        -moz-transition: all 0.3s ease-out;
        -ms-transition: all 0.3s ease-out;
        -o-transition: all 0.3s ease-out;
        transition: all 0.3s ease-out;
        opacity: 1;
      }
    }
  }
}

.icon-sd-black-14 {
  background: url("../img/icon-sd-black-14.png") 0 3px no-repeat;
  width: 11px;
  height: 17px;
  display: inline-block !important;
}

.center {
  float: none;
  margin-left: auto;
  margin-right: auto;
}

.ui-pnotify a {
  text-decoration: underline;
}

/** Styles for Bootstrap Slider */

.slider {
  .slider-selection {
    .buttonBackground(@btnPrimaryBackground, @btnPrimaryBackgroundHighlight);
  }

  &.slider-disabled .slider-selection {
    background-image: none;
    .opacity(65);
    .box-shadow(none);
  }

  .slider-track {
    background-color: @wellBackground;
    border: 1px solid darken(@wellBackground, 7%);
    .border-radius(@baseBorderRadius);
    .box-shadow(inset 0 1px 1px rgba(0,0,0,.05));
  }

  &.slider-disabled .slider-track {
    background-image: none;
    .opacity(65);
    .box-shadow(none);
  }

  .slider-handle {
    .btn;
    padding: 0;
    margin-bottom: 0;
    .opacity(100);

    &.hide {
      display: none;
    }

    &.round {
      .border-radius(50%);
    }
  }
}

.modal.large {
  width: 975px;
  margin-left: -487px;
}

.full-sized-box {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  top: 0;

  padding: 15px;

  .row-fluid {
    height: 100%;
  }

  @media (max-width: 979px) {
    position: static;
  }
}

// Special delivery for Safari browsers... because Safari >= 8 sometimes just
// shows us white panes on the settings dialog when the full-sized-box has
// an absolute position (which it needs for both scrollbars to work), at least
// until the page is resized or otherwise a rerender is triggered, we'll have
// our styling resolve to static positioning on that browser for now.
//
// This btw also means that the dialog will change in size. Yay.
//
// Better use something else if you have the option, that thing is really
// weird.
_::-webkit-full-page-media, _:future, :root .full-sized-box {
  position: static;
}

.scrollable {
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.input-append, .input-prepend {
  .add-on {
    &.add-on-limited {
      overflow-x: hidden;
      text-overflow: ellipsis;
      width: inherit;
    }
  }
}

.control-group.error .input-prepend .fileinput-button,
.control-group.error .input-append .fileinput-button {
  border-color: #b94a48;
}

input[type=number] {
  text-align: right;
}
